/**
 * 
 */
package Actions;

import Monopol.Events.MonopolyGameEvents;
import Monopol.MonopolyGame;
import Monopol.MonopolExceptions.MonopolErrors;
import java.awt.event.ActionEvent;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.AbstractAction;
import javax.swing.JOptionPane;



import Monopol.Monopol;
import Player.Player;
import java.util.Timer;
import java.util.TimerTask;

/**
 * @author Avia Tam
 * @author Assaf Miron
 *
 */
@SuppressWarnings("serial")
public class QuitAction extends AbstractAction {
    private Player player;
    int res = JOptionPane.NO_OPTION;


    /* (non-Javadoc)
     * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
     */

    public QuitAction( Player player) {
        super("Quit");
        
        this.player = player;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
 int res = JOptionPane.showConfirmDialog(null, "Are you sure you want quit", "Player leaves game", JOptionPane.YES_NO_OPTION);
                switch (res) {
                    case JOptionPane.YES_OPTION: {
            try {
                MonopolyGameEvents.getInstance().setResignedPlayer(player.getNumber());
            } catch (MonopolErrors ex) {
                Logger.getLogger(QuitAction.class.getName()).log(Level.SEVERE, null, ex);
            }
                        break;
                    }
                    default:
                    //do nothing
                }
            }
}







